from selenium import webdriver
from selenium.webdriver.common.by import By

login_url = "http://116.62.63.211/shop/user/loginInfo.html"
user_input_xpath = "/html/body/div[4]/div/div[2]/div[2]/div/div/div[1]/form/div[1]/input"
password_input_xpath = "/html/body/div[4]/div/div[2]/div[2]/div/div/div[1]/form/div[2]/div/input"
password_input_css_selector = "body > div.am-g.my-content > div > div.am-u-sm-12.am-u-md-6.am-u-lg-4.container-right > div.user-form-container > div > div > div.am-tab-panel.am-active > form > div.am-form-group.am-form-group-refreshing.business-form-block.am-margin-top-xs > div > input"
login_button_xpath = "/html/body/div[4]/div/div[2]/div[2]/div/div/div[1]/form/div[3]/button"


# 使用浏览器驱动，自动启动浏览器
driver = webdriver.Chrome()

# 隐式等待，最大等待时间为20秒
driver.implicitly_wait(20)

driver.get(login_url)

# xpath选择定位
user_input = driver.find_element(By.XPATH, user_input_xpath)
user_input.send_keys("15970794846")

# css选择定位
password_input = driver.find_element(By.CSS_SELECTOR, password_input_css_selector)
password_input.send_keys("15970794846.")

# xpath选择定位
login_button = driver.find_element("xpath", login_button_xpath)
login_button.click()

driver.close()